package com.zhengshang.api.service.impl;

import java.util.List;
import com.zhengshang.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zhengshang.api.mapper.AppGasStationMapper;
import com.zhengshang.api.domain.AppGasStation;
import com.zhengshang.api.service.IAppGasStationService;

/**
 * 加油站点信息Service业务层处理
 * 
 * @author zhengshang
 * @date 2021-04-17
 */
@Service
public class AppGasStationServiceImpl implements IAppGasStationService 
{
    @Autowired
    private AppGasStationMapper appGasStationMapper;

    /**
     * 查询加油站点信息
     * 
     * @param gasId 加油站点信息ID
     * @return 加油站点信息
     */
    @Override
    public AppGasStation selectAppGasStationById(String gasId)
    {
        return appGasStationMapper.selectAppGasStationById(gasId);
    }

    /**
     * 查询加油站点信息列表
     * 
     * @param appGasStation 加油站点信息
     * @return 加油站点信息
     */
    @Override
    public List<AppGasStation> selectAppGasStationList(AppGasStation appGasStation)
    {
        return appGasStationMapper.selectAppGasStationList(appGasStation);
    }

    @Override
    public List<AppGasStation> selectAppGasStationByLonLat(AppGasStation appGasStation) {
        return appGasStationMapper.selectAppGasStationByLonLat(appGasStation);
    }

    /**
     * 新增加油站点信息
     * 
     * @param appGasStation 加油站点信息
     * @return 结果
     */
    @Override
    public int insertAppGasStation(AppGasStation appGasStation)
    {
        if (this.selectAppGasStationById(appGasStation.getGasId()) == null) {
            appGasStation.setCreateTime(DateUtils.getNowDate());
            return appGasStationMapper.insertAppGasStation(appGasStation);
        } else {
            appGasStation.setUpdateBy(appGasStation.getCreateBy());
            return this.updateAppGasStation(appGasStation);
        }
    }

    /**
     * 修改加油站点信息
     * 
     * @param appGasStation 加油站点信息
     * @return 结果
     */
    @Override
    public int updateAppGasStation(AppGasStation appGasStation)
    {
        appGasStation.setUpdateTime(DateUtils.getNowDate());
        return appGasStationMapper.updateAppGasStation(appGasStation);
    }

    /**
     * 批量删除加油站点信息
     * 
     * @param gasIds 需要删除的加油站点信息ID
     * @return 结果
     */
    @Override
    public int deleteAppGasStationByIds(String[] gasIds)
    {
        return appGasStationMapper.deleteAppGasStationByIds(gasIds);
    }

    /**
     * 删除加油站点信息信息
     * 
     * @param gasId 加油站点信息ID
     * @return 结果
     */
    @Override
    public int deleteAppGasStationById(String gasId)
    {
        return appGasStationMapper.deleteAppGasStationById(gasId);
    }

    @Override
    public int deleteOfflineAppGasStation() {
        return appGasStationMapper.deleteOfflineAppGasStation();
    }
}
